import { ResPage, Role } from "@/api/interface";
import { ROLE_PORT } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取用户列表
export const getRoleList = (params: Role.ReqRoleParams | {}) => {
  return http.post<ResPage<Role.ResRoleList>>(ROLE_PORT + `/list`, params);
};

// 新增用户
export const addRole = (params: { id: string }) => {
  return http.post(ROLE_PORT + `/add`, params);
};

// 批量添加用户
export const BatchAddRole = (params: FormData) => {
  return http.post(ROLE_PORT + `/import`, params);
};

// 编辑用户
export const editRole = (params: { id: string }) => {
  return http.post(ROLE_PORT + `/edit`, params);
};

// 删除用户
export const deleteRole = (params: { id: string[] }) => {
  return http.post(ROLE_PORT + `/delete`, params);
};

// 切换用户状态
export const changeRoleStatus = (params: { id: string; status: number }) => {
  return http.post(ROLE_PORT + `/change`, params);
};

// 导出用户数据
export const exportRoleInfo = (params: Role.ReqRoleParams) => {
  return http.download(ROLE_PORT + `/export`, params);
};

// 获取用户状态字典
export const getRoleStatus = () => {
  return http.get<Role.ResStatus[]>(ROLE_PORT + `/status`);
};
